﻿@{
    ViewBag.Title = "Logistical";
}


@section scripts
{ 
    <script src="@Url.Content("~/Scripts/shared/share.js?v=")@ViewBag.version" type="text/javascript"></script> 
    <script src="@Url.Content("~/Scripts/shared/shown.js?v=")@ViewBag.version"type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/Base/Logistical.js?v=")@ViewBag.version"type="text/javascript"></script>        
}
       
        <div class="mini-toolbar" style="padding:2px;border-top:0;border-left:0;border-right:0;">
            <table style="width:100%;">
                <tr>
                    <td style="width:100%;">
                        <a class="mini-button" id="fresh" name="fresh" iconCls="icon-search" onclick="refresh" plain="true">刷新</a>
                        <span class="separator"></span>
                        <a class="mini-button" id="new" name="new" iconCls="icon-new" onclick="newBill" plain="true">新增</a>
                        <a class="mini-button" id="save" name="save" iconCls="icon-edit" onclick="modify" plain="true">修改</a>
                        <a class="mini-button" id="delrow" name="delrow" iconCls="icon-remove" onclick="removeInfo" plain="true">删除</a>
                        <span class="separator"></span>
                        <a class="mini-button" id="default" name="default" iconCls="icon-ok" onclick="setdefault" plain="true">默认</a>
                        <span class="separator"></span>
                        <a class="mini-button" id="close" name="close" iconCls="icon-close" onclick="CloseWindow" plain="true">关闭</a>
                    </td>
                </tr>
            </table>
        </div>
        @Html.Partial("~/Views/Modular/SearchInfo.cshtml")
        <div class="mini-fit" >
            <div id="datagrid1" class="mini-datagrid" style="width:100%;height:100%;" pageSize="15"
                    borderStyle="border:1;" url="GetList"
                    allowCellSelect="true" allowCellEdit="true"showColumnsMenu="true"fitColumns="false"  
                    onrowdblclick="modify"  sortMode="client" ondrawcell="DrawCell">
                <div property="columns">
                    <div type="checkcolumn">选行</div>
                    <div type="indexcolumn" width="40" headerAlign="center">序号</div>
                    <div field="FNumber" name="FNumber" width="100" headeralign="center" allowsort="true" required="true">编码</div>
                    <div field="FName" name="FName" width="150" headeralign="center" allowsort="true" required="true">名称</div>
                    <div field="FCalculateType" name="FCalculateType" width="100" headeralign="center" allowsort="true" required="true">计算方式</div>
                    <div field="FBaseQty" name="FBaseQty" width="80" headeralign="center" align="right" allowsort="true" numberFormat="#,0">默认件数</div>
                    <div field="FFreight" name="FFreight" width="80" headeralign="center" align="right" allowsort="true" numberFormat="#,0.00">默认运费</div>
                    <div field="FOthQty" name="FOthQty" width="80" headeralign="center" align="right" allowsort="true" numberFormat="#,0">增加件数</div>
                    <div field="FOthMoney" name="FOthMoney" width="80" headeralign="center" align="right" allowsort="true" numberFormat="#,0.00">增加运费</div>
                    <div field="FMax" name="FMax" width="80" headeralign="center" align="right" allowsort="true" numberFormat="#,0.00">基础运费</div>
                    <div field="FMin" name="FMin" width="80" headeralign="center" align="right" allowsort="true" numberFormat="#,0.00">最低配送价</div>
                    <div field="FRemark" name="FRemark" width="120" headeralign="center" allowsort="true">备注</div>
                    <div field="FDefault" name="FDefault" width="120" headeralign="center" allowsort="true">默认</div>
                </div>
            </div>
        </div>

<script>
    function setdefault(){
        var grid = mini.get("datagrid1");
        var row = grid.getSelected();
        if (row) {
            var FSystemAppID = parent.window.getSystemAppID();
            var json = "{'FItemID':'" + row.FItemID + "','mSystemAppID':'" + FSystemAppID + "'}";
            $.post("SetDefault", { mjson: json }, function (data) {
                var ret = mini.decode(data);
                if (ret.status == 1) {
                    grid.reload();
                }
                else {
                    mini.alert("异常:" + ret.error);
                }
            });
        } else {
            mini.alert("请选中一条记录");
        }

    }

    function DrawCell(e) {
        if (e.column.header == '默认') {
            if(e.row.FDefault==0)
                e.cellHtml = '否';
            else
                e.cellHtml = '是';
        }
    }

</script>